import { createRouter, createWebHashHistory, createWebHistory, Router } from 'vue-router'
import { RouterTy } from '@/typings/router'
const Layout = () => import('@/layouts/index.vue')

//首页模块重定向欢迎页 使用 /
export const constantRoutes: RouterTy = [
  {
    path: '/error',
    name: 'Error',
    component: () => import('@/views/Error.vue'),
    meta: {
      title: '浏览器',
      keepAlive: false
    }
  },
  {
    path: '/',
    name: 'Home',
    meta: {
      title: '首页',
      keepAlive: false
    },
    component: Layout,
    children: [
      {
        path: '/',
        name: 'Home',
        component: () => import('@/views/Home.vue'),
        meta: { title: '首页', keepAlive: false, showTab: true }
      }
    ]
  }
]
/* 
const router: Router = createRouter({
  history: createWebHashHistory(),
  scrollBehavior: () => ({ top: 0 }),
  routes: constantRoutes
}) 
 */
const router = createRouter({
  history: createWebHistory(), // 改为 history 模式，Nginx需要添加try_files $uri $uri/ /index.html;
  scrollBehavior: () => ({ top: 0 }),
  routes: constantRoutes
})

export default router
